import request from "@/utils/request";
import { ParseData } from "@/utils/utils";

//获取角色列表分页
export const GetRoleList = (data: any) => {
  return request({
    method: "GET",
    url: `/quanxian/juese`,
  });
};

// 启用/禁用角色
export const UpdateRoleStatus = (data: any) => {
  return request({
    method: 'PUT',
    url: `/quanxian/juese/${data.id}`
  })
}

// 添加角色
export const AddRole = (data: any) => {
  return request({
    method: 'POST',
    url: `/quanxian/juese`,
    data: data
  })
}
// 删除角色
export const DeleteRole = (data: any) => {
  return request({
    method: 'DELETE',
    url: `/quanxian/juese/${data.id}`,
    data: data
  })
}
// 编辑角色
export const UpdateRole = (data: any) => {
  return request({
    method: "PUT",
    url: `/quanxian/juese`,
    data: data,
  });
};

// 获取角色信息
export const GetRoleInfo = (data: any) => {
  return request({
    method: 'GET',
    url: `/quanxian/juese/${data.id}`,
    data: data
  })
}

// 获取角色下拉列表
export const GetRoleListAll = () => {
  return request({
    method: "GET",
    url: `/quanxian/juese/xialaliebiao`,
  });
};

//获取管理员角色列表
export const GetAdminList = (data: any) => {
  return request({
    method: "GET",
    url: `/quanxian/guanliyuan`,
    data: data,
  });
};

// 启用/禁用管理员
export const UpdateAdministrator = (data: any) => {
  return request({
    method: "PUT",
    url: `/quanxian/guanliyuan/${data.id}`,
    data: data,
  });
}

// 新增管理员
export const AddAdministrator = (data: any) => {
  return request({
    method: "POST",
    url: `/quanxian/guanliyuan`,
    data: data,
  });
};

// 获取管理员详情
export const GetAdministratorDetails = (data: any) => {
  return request({
    method: "GET",
    url: `/quanxian/guanliyuan/${data.id}`,
    data: data,
  });
};

// 编辑管理员
export const UpdateAdministratorDetails = (data: any) => {
  return request({
    method: "PUT",
    url: `/quanxian/guanliyuan`,
    data: data,
  });
};

// 删除管理员
export const DeleteAdministrator = (data: any) => {
  return request({
    method: "DELETE",
    url: `/quanxian/guanliyuan/${data.id}`,
    data: data,
  });
};


// 数据字典查询（下拉树形结构）
export const GetDictionaryTree = (data: any) => {
  return request({
    method: "GET",
    url: `/shujuzidian/xialashu?dicModel=${data.dicModel}`,
    data: data,
  });
};
// 数据字典查询（单列数据结构）
export const GetDictionary = (data: any) => {
  return request({
    method: "GET",
    url: `/shujuzidian/xialaliebiao?dicId=${data.dicId}`,
    data: data,
  });
};
// 数据字典新增
export const AddDictionary = (data: any) => {
  return request({
    method: "POST",
    url: `/shujuzidian`,
    data: data,
  });
};
// 数据字典删除
export const DeleteDictionary = (data: any) => {
  return request({
    method: "DELETE",
    url: `/shujuzidian/${data.id}`,
    data: data,
  });
};
// 数据字典编辑
export const EditDictionary = (data: any) => {
  return request({
    method: "PUT",
    url: `/shujuzidian`,
    data: data,
  });
};
// 地区列表查询
export const GetDistrict = (data: any) => {
  return request({
    method: "GET",
    url: `/region?${ParseData(data)}`,
    data: data,
  });
};
// 下载模板
export const downloadTFile = (data: any) => {
  return request({
    method: "GET",
    url: `/daorumoban/wenjian?gongnengyewu=${data.type}`,
    data: data,
  });
};
// 查询操作教程视频列表
export const GetTeachList = () => {
  return request({
    method: "GET",
    url: `caozuojiaocheng`,
  });
};
// 编辑操作教程
export const EditTeach = (data) => {
  return request({
    method: "POST",
    data,
    url: `caozuojiaocheng`,
  });
};
// 查询数据地图
export const GetDataMap = () => {
  return request({
    method: "GET",
    url: `shujuditu`,
  });
};
// 编辑数据地图
export const EditDataMap = (data: any) => {
  return request({
    method: "POST",
    data,
    url: `shujuditu`,
  });
};
// 查询引导页
export const GetNavigation = () => {
  return request({
    method: "GET",
    url: `yindaoye`,
  });
};
// 查询引导页详情
export const GetNavigationDetail = (data) => {
  return request({
    method: "GET",
    url: `yindaoye/${data.id}`,
  });
};
// 编辑引导页
export const EditNavigation = (data: any) => {
  return request({
    method: "PUT",
    data,
    url: `yindaoye`,
  });
};
// 引导页 上下架
export const ChangeNavigation = (data: any) => {
  return request({
    method: "PUT",
    data,
    url: `yindaoye/shangjia`,
  });
};
// 查询协议列表
export const GetPrivacyList = () => {
  return request({
    method: "GET",
    url: `yonghu/yinsixieyi`,
  });
};
// 查询协议详情
export const GetPrivacyDetail = (data:any) => {
  return request({
    method: "GET",
    url: `yonghu/yinsixieyi/${data.id}`,
  });
};
// 编辑协议
export const EditPrivacy = (data: any) => {
  return request({
    method: "PUT",
    data,
    url: `yonghu/yinsixieyi`,
  });
};
